package com.zsl.swing.redis.desktop.utils;

import javax.swing.*;
import java.awt.*;

public class GridBagUtils {

    private GridBagConstraints gridBagConstraints;

    private GridBagUtils(){
        this(true);
    }

    private GridBagUtils(boolean fill){
        this.gridBagConstraints = new GridBagConstraints();
        this.gridBagConstraints.anchor = GridBagConstraints.EAST;
        this.gridBagConstraints.fill = fill?GridBagConstraints.HORIZONTAL: GridBagConstraints.NONE;
    }

    public static GridBagUtils getInstance(boolean fill){
        return new GridBagUtils(fill);
    }

    public static GridBagUtils getInstance(){
        return new GridBagUtils();
    }

    public GridBagUtils add(Component f, JPanel t, int x, int y, int w , int h){
        this.gridBagConstraints.gridx = x;
        this.gridBagConstraints.gridy = y;
        this.gridBagConstraints.gridwidth = w;
        this.gridBagConstraints.gridheight = h;

        t.add(f, this.gridBagConstraints);
        return this;
    }



}
